package com.atguigu.gmall.mq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    @Bean("gmallqueue")
    public Queue createQueue(){
        return QueueBuilder.durable("gmall_queue").build();
    }

    @Bean("gmallexchange")
    public Exchange crateExchange(){
        return ExchangeBuilder.directExchange("exchange.confirm").build();
    }

    @Bean("gmallbinding")
    public Binding createBinding(@Qualifier("gmallqueue") Queue queue,@Qualifier("gmallexchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("routeing.confirm").noargs();
    }

}
